#!/bin/sh

# must not fail
set -e 

# debug
set -x 

echo "Starting $0"


NCIPHER_DISTNAME=ncipher-nCSS-linux-user-11.30.zip
NCIPHER_DIRNAME=ncipher-nCSS-linux-user-11.30
NCIPHER_UNPACKCMD=unzip


### copy to "install"

if [ ! -f ${DISTFILES_INSTALL}/${NCIPHER_DISTNAME} ] ; then 	
    echo "copying ${NCIPHER_DISTNAME} to ${DISTFILES_INSTALL}"
    cp ${NCIPHER_DISTNAME}     ${DISTFILES_INSTALL}
fi

### unpack if this version dont exist already
if [ -x ${INSTALL_INTO}/${NCIPHER_DIRNAME} ] ;then
    echo "${NCIPHER_DIRNAME} exists, skipping"
else
    cd ${INSTALL_INTO}
    ${NCIPHER_UNPACKCMD} ${DISTFILES_INSTALL}/${NCIPHER_DISTNAME} 
    cd -
fi

cd / 
tar xvf ${INSTALL_INTO}/${NCIPHER_DIRNAME}/ctls/agg.tar
tar xvf ${INSTALL_INTO}/${NCIPHER_DIRNAME}/javasp/agg.tar
tar xvf ${INSTALL_INTO}/${NCIPHER_DIRNAME}/jcecsp/user.tar
tar xvf ${INSTALL_INTO}/${NCIPHER_DIRNAME}/hwsp/agg.tar


echo "End of $0"

